package com.tihi.ui.base;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentActivity;

import com.umeng.analytics.MobclickAgent;

/**
 * 
 * @author duantihi
 * @date 2016-1-30 下午1:10:04
 */
public abstract class BaseActivity extends FragmentActivity{
	
	@Override
	protected void onCreate(@Nullable Bundle arg0) {
		super.onCreate(arg0);
		setContentView(getLayout());
		initViews();
	}
	
	@Override
	protected void onResume() {
		super.onResume();
		if(com.tihi.util.StringUtils.isNotEmpty(getTagForUmeng())){
			MobclickAgent.onPageStart(getClass().getName() + "(" + getTagForUmeng() + ")");
		} else{
			MobclickAgent.onPageStart(getClass().getName());
		}
		MobclickAgent.onResume(this);
	}
	
	@Override
	protected void onPause() {
		super.onPause();
		if(com.tihi.util.StringUtils.isNotEmpty(getTagForUmeng())){
			MobclickAgent.onPageEnd(getClass().getName() + "(" + getTagForUmeng() + ")");
		} else{
			MobclickAgent.onPageEnd(getClass().getName());
		}
		MobclickAgent.onPause(this);
	}
	
	protected abstract int getLayout();
	
	protected abstract void initViews();
	
	@Override
	protected void onDestroy() {
		super.onDestroy();
	}
	
	protected abstract String getTagForUmeng();

}
